//    LightMP3
//    Copyright (C) 2007,2008,2009 Sakya
//    sakya_tg@yahoo.it
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#define le2int(le) \
((le[0] << 0) | (le[1] << 8) | (le[2] << 16) | (le[3] << 24))

#define WMA_GUID	(unsigned char [16]) \
		      {	0x30, 0x26, 0xB2, 0x75, \
			0x8E, 0x66, \
			0xCF, 0x11, \
			0xA6, 0xD9, \
			0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C }

#define CONTENT_GUID	(unsigned char [16]) \
		      {	0x33, 0x26, 0xB2, 0x75, \
			0x8E, 0x66, \
			0xCF, 0x11, \
			0xA6, 0xD9, \
			0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C }

#define EXTENDED_GUID	(unsigned char [16]) \
		      {	0x40, 0xA4, 0xD0, 0xD2, \
			0x07, 0xE3, \
			0xD2, 0x11, \
			0x97, 0xF0, \
			0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50 }

#define WMA_SDKVERSION (unsigned char [25]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x46,0x00,0x53,0x00,0x44,0x00,0x4B,0x00,0x56,0x00,0x65,0x00, \
                        0x72,0x00,0x73,0x00,0x69,0x00,0x6F,0x00,0x6E \
                        }

#define WMA_SDKNEEDED (unsigned char [23]) \
                        { \
                        0x57,0x00,0x4D,0x00, \
                        0x46,0x00,0x53,0x00,0x44,0x00,0x4B,0x00,0x4E,0x00,0x65,0x00,0x65,0x00,0x64,0x00, \
                        0x65,0x00,0x64 \
                        }

#define WMA_TRACK (unsigned char [15]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x54,0x00, \
                        0x72,0x00,0x61,0x00,0x63,0x00,0x6B \
                        }

#define WMA_TRACKNUMBER	(unsigned char [27]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00, \
                        0x54,0x00,0x72,0x00,0x61,0x00,0x63,0x00,0x6B,0x00,0x4E,0x00,0x75,0x00,0x6D,0x00, \
                        0x62,0x00,0x65,0x00,0x72 \
                        }

#define WMA_ALBUMARTIST	(unsigned char [27]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x41,0x00,0x6C,0x00, \
                        0x62,0x00,0x75,0x00,0x6D,0x00,0x41,0x00,0x72,0x00,0x74,0x00,0x69,0x00,0x73,0x00, \
                        0x74 \
                        }
#define WMA_RATING	(unsigned char [37]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x53,0x00,0x68,0x00,0x61,0x00, \
                        0x72,0x00,0x65,0x00,0x64,0x00,0x55,0x00,0x73,0x00,0x65,0x00,0x72,0x00,0x52,0x00, \
                        0x61,0x00,0x74,0x00,0x69,0x00,0x6E,0x00,0x67 \
                        }

#define WMA_ALBUMTITLE	(unsigned char [25]) \
                        { \
                        0x57,0x00,0x4D,0x00, \
                        0x2F,0x00,0x41,0x00,0x6C,0x00,0x62,0x00,0x75,0x00,0x6D,0x00,0x54,0x00,0x69,0x00, \
                        0x74,0x00,0x6C,0x00,0x65 \
                        }

#define WMA_YEAR	(unsigned char [13]) \
                        { \
                        0x57,0x00, \
                        0x4D,0x00,0x2F,0x00,0x59,0x00,0x65,0x00,0x61,0x00,0x72 \
                        }

#define WMA_GENRE	(unsigned char [15]) \
                        { \
                        0x57,0x00, \
                        0x4D,0x00,0x2F,0x00,0x47,0x00,0x65,0x00,0x6E,0x00,0x72,0x00,0x65 \
                        }

#define WMA_LYRICS	(unsigned char [17]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x4C,0x00,0x79,0x00,0x72,0x00,0x69,0x00,0x63,0x00, \
                        0x73 \
                        }

#define WMA_URL	(unsigned char [29]) \
                        { \
                        0x57,0x00,0x4D,0x00, \
                        0x2F,0x00,0x50,0x00,0x72,0x00,0x6F,0x00,0x6D,0x00,0x6F,0x00,0x74,0x00,0x69,0x00, \
                        0x6F,0x00,0x6E,0x00,0x55,0x00,0x52,0x00,0x4C \
                        }

#define WMA_ENCODEDBY	(unsigned char [23]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x45,0x00,0x6E,0x00,0x63,0x00, \
                        0x6F,0x00,0x64,0x00,0x65,0x00,0x64,0x00,0x42,0x00,0x79 \
                        }


#define WMA_COMPOSER	(unsigned char [21]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x43,0x00,0x6F,0x00, \
                        0x6D,0x00,0x70,0x00,0x6F,0x00,0x73,0x00,0x65,0x00,0x72 \
                        }

#define WMA_PICTURE	(unsigned char [19]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x50,0x00,0x69,0x00, \
                        0x63,0x00,0x74,0x00,0x75,0x00,0x72,0x00,0x65 \
                        }

#define WMA_ISVBR (unsigned char [9]) \
                        { \
                        0x49,0x00,0x73,0x00,0x56,0x00,0x42,0x00,0x52 \
                        }

#define WMA_ENCODINGTIME (unsigned char [29]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x45,0x00,0x6E,0x00,0x63,0x00,0x6F,0x00,0x64,0x00, \
                        0x69,0x00,0x6E,0x00,0x67,0x00,0x54,0x00,0x69,0x00,0x6D,0x00,0x65 \
                        }

#define WMA_FILEID (unsigned char [45]) \
                        { \
                        0x57,0x00, \
                        0x4D,0x00,0x2F,0x00,0x55,0x00,0x6E,0x00,0x69,0x00,0x71,0x00,0x75,0x00,0x65,0x00, \
                        0x46,0x00,0x69,0x00,0x6C,0x00,0x65,0x00,0x49,0x00,0x64,0x00,0x65,0x00,0x6E,0x00, \
                        0x74,0x00,0x69,0x00,0x66,0x00,0x69,0x00,0x65,0x00,0x72 \
                        }

#define WMA_PUBLISHER (unsigned char [23]) \
                        { \
                        0x57,0x00, \
                        0x4D,0x00,0x2F,0x00,0x50,0x00,0x75,0x00,0x62,0x00,0x6C,0x00,0x69,0x00,0x73,0x00, \
                        0x68,0x00,0x65,0x00,0x72 \
                        }

#define WMA_MEDIAID (unsigned char [43]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x4D,0x00,0x65,0x00,0x64,0x00, \
                        0x69,0x00,0x61,0x00,0x50,0x00,0x72,0x00,0x69,0x00,0x6D,0x00,0x61,0x00,0x72,0x00, \
                        0x79,0x00,0x43,0x00,0x6C,0x00,0x61,0x00,0x73,0x00,0x73,0x00,0x49,0x00,0x44 \
                        }

#define WMA_MCDI (unsigned char [13]) \
                        { \
                        0x57,0x00,0x4D,0x00,0x2F,0x00,0x4D,0x00,0x43,0x00,0x44,0x00, \
                        0x49 \
                        }

#define WMA_TAG_BUFFER_SIZE 1024*300


#define WMA_JPEG (unsigned char [3]) \
                        { \
                        0xFF,0xD8,0xFF \
                        }

#define WMA_PNG (unsigned char [16]) \
                        { \
                        0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A,0x00,0x00,0x00,0x0D,0x49,0x48,0x44,0x52 \
                        }

typedef struct
{
    char name[30];
    char value[256];
    int start;
    int size;
} wmaTagValue;


typedef struct
{
    int titleLen;
    char title[256];
    int authorLen;
    char author[256];
    int descriptionLen;
    char description[256];
    int copyrightLen;
    char copyright[256];
} wmaContentTag;


int wmaReadTag(unsigned char *buffer, int position, wmaTagValue *tag);
int wmaReadContentTag(unsigned char *buffer, int startPos, wmaContentTag *contentTag);
int wmaSearchExtendedStart(unsigned char *buffer, int startPos, int maxSearch);
int wmaSearchContentStart(unsigned char *buffer, int startPos, int maxSearch);

